<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "express_callback".
 *
 * @property int $id
 * @property string|null $waybill
 * @property string|null $shopbill
 * @property string|null $type
 * @property int|null $typeCode
 * @property float|null $weight
 * @property float|null $realWeight
 * @property float|null $transferWeight
 * @property float|null $calWeight
 * @property float|null $volume
 * @property float|null $parseWeight
 * @property float|null $totalFreight
 * @property float|null $freight
 * @property float|null $freightInsured
 * @property float|null $freightHaocai
 * @property string|null $changeBill
 * @property float|null $changeBillFreight
 * @property int|null $feeOver
 * @property string|null $linkName
 * @property int|null $billType
 * @property string|null $comments
 * @property string|null $courierPhone
 * @property string|null $courierName
 * @property string|null $pickupCode
 * @property float|null $totalPrice
 * @property string|null $extendField1
 * @property string|null $extendField2
 * @property string|null $extendField3
 * @property string $create_time
 * @property int $status 0未处理 1已处理
 * @property string $update_time
 */
class ExpressCallback extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'express_callback';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['typeCode', 'feeOver', 'billType', 'status'], 'integer'],
            [['weight', 'realWeight', 'transferWeight', 'calWeight', 'volume', 'parseWeight', 'totalFreight', 'freight', 'freightInsured', 'freightHaocai', 'changeBillFreight', 'totalPrice'], 'number'],
            [['create_time', 'update_time'], 'safe'],
            [['waybill', 'shopbill', 'type', 'changeBill', 'linkName', 'comments', 'courierPhone', 'courierName', 'pickupCode', 'extendField1', 'extendField2', 'extendField3'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'waybill' => 'Waybill',
            'shopbill' => 'Shopbill',
            'type' => 'Type',
            'typeCode' => 'Type Code',
            'weight' => 'Weight',
            'realWeight' => 'Real Weight',
            'transferWeight' => 'Transfer Weight',
            'calWeight' => 'Cal Weight',
            'volume' => 'Volume',
            'parseWeight' => 'Parse Weight',
            'totalFreight' => 'Total Freight',
            'freight' => 'Freight',
            'freightInsured' => 'Freight Insured',
            'freightHaocai' => 'Freight Haocai',
            'changeBill' => 'Change Bill',
            'changeBillFreight' => 'Change Bill Freight',
            'feeOver' => 'Fee Over',
            'linkName' => 'Link Name',
            'billType' => 'Bill Type',
            'comments' => 'Comments',
            'courierPhone' => 'Courier Phone',
            'courierName' => 'Courier Name',
            'pickupCode' => 'Pickup Code',
            'totalPrice' => 'Total Price',
            'extendField1' => 'Extend Field 1',
            'extendField2' => 'Extend Field 2',
            'extendField3' => 'Extend Field 3',
            'create_time' => 'Create Time',
            'status' => 'Status',
            'update_time' => 'Update Time',
        ];
    }

    public function beforeSave($insert)
    {
        if (parent::beforeSave($insert)) {
            $time = date('Y-m-d H:i:s');
            $this->update_time = $time;
            if ($insert) {
                $this->create_time = $time;
            }
            return true;
        }
        return false;
    }
}
